Skip to content

[refactor] Split the 4,467-line lib.rs into domain modules - #273

Closed
annamary224411-sudo wants to merge 2 commits into
MarketXpress:mainfrom
annamary224411-sudo:main
Closed

[refactor] Split the 4,467-line lib.rs into domain modules#273
annamary224411-sudo wants to merge 2 commits into
MarketXpress:mainfrom
annamary224411-sudo:main

Conversation

@annamary224411-sudo

Copy link
Copy Markdown
Contributor

Summary

  • Refactored the contracts/marketx contract by splitting the single 4,467-line lib.rs into focused domain modules.
  • Preserved the existing public contract surface, Contract type, exported function names, events, and types.
  • Removed unused artifacts and moved coverage tooling outside the contract crate.
  • Improved maintainability, reviewability, onboarding, and reduced the likelihood of merge conflicts.

Linked Issue

Closes #261

CI Checklist

Before requesting review, confirm all required checks pass locally:

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test
  • ./scripts/build_wasm.sh — blocked by the local Rust toolchain because the wasm32v1-none target is not installed.

Notes for Reviewers

Motivation

  • Break up the single 4,467-line lib.rs into focused, reviewable domain modules to reduce merge conflicts and speed onboarding.
  • Keep the public contract surface and single Contract type identical while moving implementation code into logical files covering escrow lifecycle, admin, fees, arbiters, milestones, group buys, time-locks, mediation, multi-arbiter voting, token controls, and utilities.
  • Remove dead/unused artifacts from the contract crate and ensure coverage tooling is not compiled into the WASM.

Description

  • Replaced the large contracts/marketx/src/lib.rs implementation with a compact root that declares and re-exports modules and types while retaining a single #[contract] pub struct Contract; entrypoint.

  • Split the implementation into domain files under contracts/marketx/src/:

    • admin
    • arbiters
    • escrow
    • fees
    • group_buys
    • lifecycle
    • mediation
    • milestones
    • multi_arbiter
    • time_locks
    • token_controls
    • utilities
  • Kept the existing errors and types modules in place.

  • Moved tarpaulin.rs out of the contract crate into tools/tarpaulin.rs.

  • Deleted the unused Automation.rs.

  • Adjusted helper visibility to pub(crate) where required so internal modules can share implementation helpers without unnecessarily expanding the public API.

  • Verified public API parity by comparing exported pub fn names before and after the refactor.

  • Preserved existing events and types with no public function renames or intentional API changes.

  • Commit: refactor: split contract into domain modules

Testing

  • cargo fmt --all -- --check — passed.
  • cargo clippy --all-targets -- -D warnings — passed with no warnings.
  • cargo test — passed: 128 unit tests + 2 integration tests.
  • ./scripts/build_wasm.sh — could not complete in the current environment because the wasm32v1-none Rust target is not installed. The toolchain reports E0463: can't find crate for core and indicates that rustup target add wasm32v1-none is required.

The WASM build failure appears to be an environment/toolchain setup issue rather than a compilation error in the refactored contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor] Split the 4,467-line lib.rs into domain modules

1 participant